﻿using System.Collections;
using System.Collections.Generic;
using tophd.Classes.Helper;
using tophd.Models.Entity;

namespace tophd.Models.Service
{
    public class ImageService
    {
        public List<Images> GetImages(long? cateId,long? oderby, int minrow, int maxrow )
        {
            JsonHelper<Images> jsonImages = new JsonHelper<Images>();
            Hashtable hashtable = new Hashtable();
            hashtable.Add("categoryId", cateId);
            hashtable.Add("orderBy", oderby); //0: Create_date,1:download,2: position,3: name
            hashtable.Add("minRow", minrow); //phan trang
            hashtable.Add("maxRow", maxrow);
            string result = jsonImages.GetJsonResponse("getImage", hashtable);
            List<Images> listImages = jsonImages.ParseJsonResponse(result, "getImageResponse");
            return listImages;
        }

        public Images GetDetailImages(long id)
        {
            List<Images> listImages = GetImages(0, 1, 0, 0);
            foreach (Images image in listImages)
            {
                if (image.Icon == id)
                {
                    return image;
                }
            }
            return null;
        }
    }
}